<script type="text/javascript" src="java/formval.js"></script>
<script type="text/javascript">
function validateOnSubmit(formElem) {
	var elem;
	var errs=0;
	if (!validatePresent(formElem.KategorieID,  'KategorieError', true))  		errs = 1;
	
	if (errs==0){
		formElem.submit();
	}
};
</script>
<?php
function GetKategorie(& $KategorieList, $selectID) {
	$sql = "select * FROM kategorie";
	global $_db_link;
	$_rd = mysql_query($sql, $_db_link);
	if ($_rd) {
		while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
			$datakategorie[] = $daten;
		}
	}
	if ($selectID == NULL || $selectID == 0) {
		$KategorieList = $KategorieList . '<option value="" selected="selected">Please Select</option>';
	} else {
		$KategorieList = $KategorieList . '<option value="">Please Select</option>';
	}
	$KategorieList = $KategorieList . getOption(& $datakategorie, $selectID);
	$KategorieList = $KategorieList . "</select>";
}
if(!empty($_SESSION["CMS_User"]["ID"])){
	$MoudeTagID = $_GET["MoudeTagID"];
	if($_POST){
		if(!empty($_POST["KategorieID"])){//edit
			$KategorieID=$_POST["KategorieID"];
			$sql="update tagmodule set
				setting= $KategorieID
				where ID=$MoudeTagID";
			$_rd=mysql_query($sql,$_db_link);
			GotoURL("index.php?tag=$TagID");
		}
	}
}

if($MoudeTagID){
	$sql="select * FROM tagmodule WHERE ID=$MoudeTagID";
	$_rd= mysql_query($sql,$_db_link);
	if($_rd){
		$daten=mysql_fetch_array($_rd,MYSQL_ASSOC);
	}
	$KategorieList = '<select name="KategorieID" id="KategorieID" onchange="validatePresent(this, \'KategorieError\');">';
	GetKategorie($KategorieList, $daten["Setting"]);
	?>
<div style="width: 100%; background-color: #F1EEF3; margin: 0px">
<table class="tableEdit">

	<tr>
		<td class="lableEdit"><?PHP  LangText("KategorieID");?>:</td>
		<td class="inputEdit"><?PHP echo $KategorieList; ?></td>
		<td class="validateEdit"><input type="label" DISABLED
			id="KategorieError" value='<?PHP LangText("KategorieError");?>' /></td>
	</tr>

	<tr>
		<td class="lableEdit"></td>
		<td class="inputEdit"><input type="button"
			onclick="validateOnSubmit(this.form);" class="BootenLink"
			value='<?PHP LangText("Bearbeiten"); ?>' /> <input type="button"
			onclick="window.location='index.php?tag=<?PHP echo $_GET['tag']; ?>'"
			class="BootenLink" value='<?PHP LangText("Abbrechen");?>' /></td>
		<td class="validateEdit"></td>
	</tr>
</table>
</div>

	<?php
}
?>